/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.compomics.proteomusicplayer.MS1;

import static com.compomics.proteomusicplayer.MS2.SpectrumPlayer.playSpectrum;
import com.compomics.util.experiment.massspectrometry.Spectrum;
import com.compomics.util.experiment.massspectrometry.SpectrumFactory;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import org.apache.commons.math.MathException;
import uk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException;

/**
 *
 * @author Kenneth
 */
public class Playground {

    static File mgf = new File("C:\\Users\\Kenneth\\Documents\\Projects\\testing_repo\\Pride_FTP\\11954\\pride_exp_complete_ac_11954.mgf");
    static int sampleRate = 16;

    public static void main(String[] args) throws IOException, MzMLUnmarshallerException, MathException {
        SpectrumFactory factory = SpectrumFactory.getInstance();
        factory.clearFactory();
        factory.addSpectra(mgf, null);
        ArrayList<String> spectrumTitles = factory.getSpectrumTitles(mgf.getName());
        // Play the song!
        for (String aSpectrumTitle : spectrumTitles) {
            try {
                Spectrum aSpectrum = factory.getSpectrum(mgf.getName(), aSpectrumTitle);
                byte[] soundWave = SpectrumToSineTransformer.getSineFromSpectrum(aSpectrum);
                SpectrumPlayer.play(soundWave, sampleRate);
            } catch (IOException | MathException | MzMLUnmarshallerException e) {
                e.printStackTrace();
            }
        }
    }
}
